package Exam.ArrayListDemo;

import java.lang.reflect.Array;
import java.util.ArrayList;

public class ArraylistDemo2 {
    public static void main(String[] args) {

        //定义一个集合，添加字符串，并进行遍历，且格式为[1,2,3,4,...,n]
        ArrayList<String> list= new ArrayList<>();

        list.add("周");
        list.add("靖");
        list.add("松");
        list.add("畜");

        System.out.print("[");
        for (int i = 0; i < list.size(); i++) {
            if(i == list.size() - 1 ){
                System.out.print(list.get(i));
            }else{
                System.out.print(list.get(i) + ",");
            }
        }
        System.out.println("]");
        System.out.println(list.size());
    }
}
